package com.zmn.plat.services.impl.channel;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zmn.common.utils.date.DateUtil;
import com.zmn.plat.model.entity.channel.ChannelCommission;
import com.zmn.plat.persistence.interfaces.channel.ChannelCommissionDAO;
import com.zmn.plat.services.interfaces.channel.ChannelCommissionService;

/**
 * 渠道佣金
 *
 * @author xiangjunming
 * @since 2019 /08/19 12:12:02
 */
@Service
public class ChannelCommissionServiceImpl implements ChannelCommissionService {

    @Autowired
    private ChannelCommissionDAO channelCommissionDAO;

    @Override
    public ChannelCommission findByKey(Integer id) {
        return channelCommissionDAO.findByKey(id);
    }

    @Override
    public List<ChannelCommission> listByCommissionNewNotNull() {
        return channelCommissionDAO.listByCommissionNewNotNull();
    }

    @Override
    public List<ChannelCommission> listByChannelId(Integer channelId) {
        return channelCommissionDAO.listByChannelId(channelId);
    }

    @Override
    public ChannelCommission findByChannelIdAndServCategId(Integer channelId, Integer servCategId) {
        return channelCommissionDAO.findByChannelIdAndServCategId(channelId, servCategId);
    }

    @Override
    public int updateByKey(ChannelCommission record) {
        record.setUpdateTime(DateUtil.getNow());
        return channelCommissionDAO.updateByKey(record);
    }

    @Override
    public int updateByKeySelective(ChannelCommission record) {
        record.setUpdateTime(DateUtil.getNow());
        return channelCommissionDAO.updateByKeySelective(record);
    }

    @Override
    public int insert(ChannelCommission record) {
        record.setCreateTime(DateUtil.getNow());
        record.setUpdateTime(DateUtil.getNow());
        return channelCommissionDAO.insert(record);
    }

    @Override
    public int deleteByKey(Integer id) {
        return channelCommissionDAO.deleteByKey(id);
    }

    @Override
    public void copy(Integer originalChannelId, int targetChannelId, String operator) {

        channelCommissionDAO.copy(originalChannelId, targetChannelId, operator);
    }
}